<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>

    <title>Doctor E</title>

    <link rel="shortcut icon" href="assets/img/logo2x.png"/>
    <!-- Bootstrap core CSS -->
    <link href="assets/css/bootstrap.css" rel="stylesheet"/>
    <!--external css-->
    <link rel="stylesheet" type="text/css" href="assets/font-awesome/css/font-awesome.css"/>
    <link rel="stylesheet" type="text/css" href="assets/lineicons/style.css">

    <!-- Custom styles for this template -->
    <link href="assets/css/style.css" rel="stylesheet">
    <link href="assets/css/style-responsive.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>

<section id="container">

    <div th:replace="tools :: header"></div>

    <div th:replace="tools :: sidebar "></div>

    <!-- **********************************************************************************************************************************************************
    MAIN CONTENT
    *********************************************************************************************************************************************************** -->
    <!--main content start-->

    <section id="main-content">
        <section class="wrapper site-min-height">

            <div class="row col-lg-12">
                <div class="form-panel col-lg-12">
                    <div class="col-lg-12 btn-group">
                        <button class="btn " onclick="window.history.back()"><i class="fa fa-angle-left"></i> 返 回
                        </button>
                        <button class="btn " onclick="javascript:location.reload();"><i class="fa fa-refresh"></i> 刷新
                        </button>
                        <button class="btn btn-success" onclick="updateMdc()"> 保 存</button>
                        <button class="btn btn-danger" onclick="delMdc()"> 从药库中删除 </button>
                    </div>
                </div>

                <div class="form-panel col-lg-12">
                    <h3 class="centered"><i class="fa fa-angle-right"></i> 药品信息 <i class="fa fa-angle-left"></i></h3>
                    <hr>
                    <form id="mdinfo" class="col-lg-12">
                        <div class="col-md-6">
                            <label class="h4">药品编号：</label>
                            <input type="text" class="h4 form-control" th:value="${md.mid}" name="mid" readonly>
                        </div>
                        <div class="col-md-6">
                            <label class="h4">生产商</label>
                            <input type="text" class="h4 form-control" th:value="${md.producer.pdname}" readonly>
                        </div>
                        <div class="col-md-6">
                            <label class="h4">药名</label>
                            <input type="text" class="h4 form-control" th:value="${md.name}" name="name">
                        </div>
                        <div class="col-md-6">
                            <label class="h4">类别</label>
                            <input type="text" class="h4 form-control" th:value="${md.type}" name="type">
                        </div>

                        <div class="col-md-6">
                            <label class="h4">价格</label>
                            <input type="number" class="h4 form-control" th:value="${md.price}" name="price">
                        </div>
                        <div class="col-md-6" th:if="${sd} != null">
                            <label class="h4">库存数量</label>
                            <input type="number" class="h4 form-control" th:value="${sd.amount}" name="amount">
                        </div>
                        <div class="col-md-12">
                            <label class="h4">规格</label>
                            <input type="text" class="h4 form-control" rows="2" th:value="${md.specification}"
                                   name="specification">
                        </div>
                        <div class="col-md-12">
                            <label class="h4">功效</label>
                            <textarea class="form-control" rows="4" th:text="${md.function}" name="function"></textarea>
                        </div>
                        <div class="col-md-12">
                            <label class="h4">成分</label>
                            <textarea class="form-control" rows="4" th:text="${md.ingredient}"
                                      name="ingredient"></textarea>
                        </div>
                        <div class="col-md-12">
                            <label class="h4">详细说明</label>
                            <textarea class="form-control" rows="4" th:text="${md.details}" name="details"></textarea>
                        </div>
                    </form>
                </div>


            </div>

        </section>
        <! --/wrapper -->

    </section>

    <!--main content end-->

    <!--**********************************************************************************************
    Footer
    **********************************************************************************************-->

    <!--footer start-->
    <footer class="site-footer">
        <div class="text-center">
            Copyright © 2018 David Bai
            <a href="#main-content" class="go-top">
                <i class="fa fa-angle-up"></i>
            </a>
        </div>
    </footer>
    <!--footer end-->
</section>


<!-- js placed at the end of the document so the pages load faster -->
<script src="assets/js/jquery.js"></script>
<script src="assets/js/jquery-1.8.3.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script class="include" type="text/javascript" src="assets/js/jquery.dcjqaccordion.2.7.js"></script>
<script src="assets/js/jquery.scrollTo.min.js"></script>
<script src="assets/js/jquery.nicescroll.js" type="text/javascript"></script>
<script src="assets/js/jquery.sparkline.js"></script>

<!--common script for all pages-->
<script src="assets/js/common-scripts.js"></script>
<script>
    function updateMdc() {
        $.post("/udmedicine", $("#mdinfo").serialize(), function (data) {
            alert(data.message);
            location.reload();
        });
    }
</script>
</body>
</html>
